package com.jinzecloud.fiction.vo;

import com.alibaba.fastjson2.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 分类表
 * 
 * @author ??
 * @email 1971240051@qq.com
 * @date 2023-10-19 19:38:04
 */
@Data
@TableName("tb_carte")
public class TbCarteGetNameAndIdVo implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 分类id
	 */
	@TableId
	private Integer caId;
	/**
	 * 分类名称
	 */
	private String caName;
	/**
	 * 父id
	 */
	private Integer caParent;
	/**
	 * 子分类
	 */
	@TableField(exist = false)
	@JSONField(serialize = false)
	@JsonInclude(JsonInclude.Include.NON_EMPTY)
	private List<TbCarteGetNameAndIdVo> children;

	public TbCarteGetNameAndIdVo addChildren(TbCarteGetNameAndIdVo carteVo) {
		if (children == null) children = new ArrayList<>();
		children.add(carteVo);
		return this;
	}

}
